﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using MiserBlogData.Entities;
using MiserBlogMVC.Models;

namespace MiserBlogMVC.Filter
{
    public class AuthorUserVIPFilterAttribute : FilterAttribute, IActionFilter
    {

        #region IActionFilter 成员

        public void OnActionExecuted(System.Web.Mvc.ActionExecutedContext filterContext)
        {

            //filterContext.RouteData.
            
            return;

        }

        public void OnActionExecuting(System.Web.Mvc.ActionExecutingContext filterContext)
        {
            UserVIPIdentity userVIPIdentity = new UserVIPIdentity();
            UserPrincipal userVIPPrincipal = new UserPrincipal(userVIPIdentity);
            filterContext.HttpContext.User = userVIPPrincipal;
            if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
            {
                filterContext.Result = new RedirectResult("/account/logon");
            }

            return;
        }

        #endregion
    }
}
